<script lang="ts" setup>
import { ref } from 'vue'
import type { MenuFunctionsInterface } from 'hicor-ui/es/components/top-menu/src/type'

const navigate = (menu: MenuFunctionsInterface) => {
  console.log('navigate', menu)
}
const close = (
  newRouteHistories: MenuFunctionsInterface[],
  target: MenuFunctionsInterface[]
) => {
  console.log('close', newRouteHistories, target)
}
const closeLeft = (
  newRouteHistories: MenuFunctionsInterface[],
  target: MenuFunctionsInterface[]
) => {
  console.log('closeLeft', newRouteHistories, target)
}
const closeRight = (
  newRouteHistories: MenuFunctionsInterface[],
  target: MenuFunctionsInterface[]
) => {
  console.log('closeRight', newRouteHistories, target)
}
const closeOther = (
  newRouteHistories: MenuFunctionsInterface[],
  target: MenuFunctionsInterface[]
) => {
  console.log('closeOther', newRouteHistories, target)
}
const closeAll = (index: number) => {
  console.log('index', index)
}
const updateRouteHistories = (newRouteHistories: MenuFunctionsInterface[]) => {
  routeHistories.value = newRouteHistories
}
const routeHistories = ref<MenuFunctionsInterface[]>([
  {
    id: '172298368964558848',
    parentId: '149099626199449600',
    sysCode: 'cpoe',
    systemId: '149099458477621248',
    funcType: '2',
    funcCode: 'projectsWithinTheSection',
    funcName: '科内项目信息',
    funcSort: '0',
    funcHome: 'Y',
    funcParam: null,
    enableFlag: 'Y',
    pyCode: null,
    wbCode: null,
    funcIcon: 'StarFilled',
    funcPath: '/cpoe/projectsWithinTheSection',
    children: null,
    isOpen: false,
    check: false,
    sysIdentifier: 'cpoe',
    url: '//192.168.20.54:8080/ui/cpoe/',
    path: '/cpoe/cpoe/projectsWithinTheSection',
    isActive: false,
    enableClose: true,
    enableNavigate: true,
    keepAlive: true,
  },
  {
    id: '149894979102375936',
    parentId: '149099626199449600',
    sysCode: 'cpoe',
    systemId: '149099458477621248',
    funcType: '2',
    funcCode: 'cpoe',
    funcName: '疾病分类',
    funcSort: '4',
    funcHome: 'N',
    funcParam: null,
    enableFlag: 'Y',
    pyCode: null,
    wbCode: null,
    funcIcon: 'StarFilled',
    funcPath: '/cpoe/icd',
    children: null,
    isOpen: false,
    check: false,
    sysIdentifier: 'cpoe',
    url: '//192.168.20.54:8080/ui/cpoe/',
    path: '/cpoe/cpoe/icd',
    isActive: false,
    enableClose: true,
    enableNavigate: true,
    keepAlive: true,
  },
  {
    id: '309025008708157440',
    parentId: '149099626199449600',
    sysCode: 'cpoe',
    systemId: '149099458477621248',
    funcType: '2',
    funcCode: 'pts_subsequentvisit',
    funcName: '复诊预约登记',
    funcSort: '7',
    funcHome: 'N',
    funcParam: null,
    enableFlag: 'Y',
    pyCode: null,
    wbCode: null,
    funcIcon: null,
    funcPath: '/pts/subsequentVisit',
    children: null,
    isOpen: false,
    check: false,
    sysIdentifier: 'cpoe',
    url: '//192.168.20.54:8080/ui/pts/',
    path: '/cpoe/pts/subsequentVisit',
    isActive: false,
    enableClose: true,
    enableNavigate: true,
    keepAlive: true,
  },
  {
    id: '309024899580755968',
    parentId: '149099626199449600',
    sysCode: 'cpoe',
    systemId: '149099458477621248',
    funcType: '2',
    funcCode: 'pts_handlehospitalcard',
    funcName: '住院证办理',
    funcSort: '6',
    funcHome: 'N',
    funcParam: null,
    enableFlag: 'Y',
    pyCode: null,
    wbCode: null,
    funcIcon: null,
    funcPath: '/pts/handleHospitalCard',
    children: null,
    isOpen: false,
    check: false,
    sysIdentifier: 'cpoe',
    url: '//192.168.20.54:8080/ui/pts/',
    path: '/cpoe/pts/handleHospitalCard',
    isActive: true,
    enableClose: true,
    enableNavigate: true,
    keepAlive: true,
  },
] as MenuFunctionsInterface[])
</script>

<template>
  <div>
    <hc-route-history
      :route-histories="routeHistories"
      @navigate="navigate"
      @close="close"
      @close-left="closeLeft"
      @close-right="closeRight"
      @close-other="closeOther"
      @close-all="closeAll"
      @update:route-histories="updateRouteHistories"
    />
  </div>
</template>
